function SalNorm = sal(color_img);
gray_img = rgb2gray(color_img);
dmgray = im2double(gray_img);

%Create DoG filters, 8x8 and 32x32
%Use your function that you developed for last HW assignment
%Parameters:
%DoG8: image size 8x8, 
%sigmaex = .04
%sigmainh = .16
%FirstTerm = 6.0
%SecondTerm = 1.0
%filterScale = .41

%DoG32: imageSize  32;
%sigmaex = .05
%sigmainh = .15
%FirstTerm = 7.0
%SecondTerm = 1.0
%filterScale = .06

dog8 = DoG(8, 0.04, 0.16, 6.0, 1.0, 0.41);
dog32 = DoG(32, 0.05, 0.15, 7.0, 1.0, 0.06);

%Convolve the grayscale image with each DoG filter and take absolute value
%Display the Contrast images, label as im8Contrast and im32Contrast

im8 = conv2(dmgray, dog8, 'same');
im8 = abs(im8);
im32 = conv2(dmgray, dog32, 'same');
im32 = abs(im32);

%Create Gabor orientation Filters
%Use MakeGrating2 code given in previous class lecture
%Write your own function based on lecture notes
%Use parameters given:
Gabor_cos0 = MakeGrating2(0, 10, 2);  %zero degrees
Gabor_cos45 = MakeGrating2(45, 10, 2);  %45 degrees
Gabor_cos90 = MakeGrating2(90, 10, 2);
Gabor_cos135 = MakeGrating2(135, 10, 2);

%Convolve Gabor functions with each Contrast image, take absolute value and display resulting
%image
im8_45 = conv2(im8, Gabor_cos45, 'same');
im32_45 = conv2(im32, Gabor_cos45, 'same');

im8_0 = conv2(im8, Gabor_cos0, 'same');
im32_0 = conv2(im32, Gabor_cos0, 'same');

im8_90 = conv2(im8, Gabor_cos90, 'same');
im32_90 = conv2(im32, Gabor_cos90, 'same');

im8_135 = conv2(im8, Gabor_cos135, 'same');
im32_135 = conv2(im32, Gabor_cos135, 'same');

%Combine and normalize Contrast images. The imContrastNormalized image
%should have a maximum value of 1.0
imContrast = (im8 + im32) / 2.0;
imContrastNormalized = mat2gray(imContrast);

%Combine and normalize Orientation images

%First combine 45 degree orientation maps for both im8 and im32, then
%normalize so that max value is 1.0
imOrientation45 = (im8_45 + im32_45) / 2.0;
imOrientationNormalized45 = mat2gray(imOrientation45);

%First combine 0 degree orientation maps for both im8 and im32, then
%normalize so that max value is 1.0
imOrientation0 = (im8_0 + im32_0) / 2.0;
imOrientationNormalized0 = mat2gray(imOrientation0);

%First combine 0 degree orientation maps for both im8 and im32, then
%normalize so that max value is 1.0
imOrientation90 = (im8_90 + im32_90) / 2.0;
imOrientationNormalized90 = mat2gray(imOrientation90);

%First combine 0 degree orientation maps for both im8 and im32, then
%normalize so that max value is 1.0
imOrientation135 = (im8_135 + im32_135) / 2.0;
imOrientationNormalized135 = mat2gray(imOrientation135);

%Combine normalized 45 and 0 degree normalized maps
imOrientationCombined = (imOrientation0 + imOrientation45 + imOrientation90 + imOrientation135);
imOrientationCombinedNorm = mat2gray(imOrientationCombined);

%Saliency map - Now Contrast and Orientation combined and normalized
Sal = (imContrast + imOrientationCombined) / 2.0;
SalNorm = mat2gray(Sal);
